import { createRouter, createWebHashHistory} from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {path:'/',redirect:'/profile'},
    {path:'/profile',component:()=>import('@/views/ProfileEdit.vue'),meta:{title:'个人资料'}},
    {path:'/address',component:()=>import('@/views/AddressManager.vue'),meta:{title:'地址列表'}},
    {path:'/address/edit/:id?',component:()=>import('@/views/AddressEdit.vue'),meta:{title:'地址管理'}}
  ]
})

//路由守卫:前置和后置守卫,前置:跳转页面显示之前,后置:跳转页面显示之后
router.afterEach((to)=>{
  //to
  document.title = to.meta.title as string
})

export default router
